<?php

class CourseController  extends BaseController {
    
    /**
     * 显示大类课程列表
     */
    public function chooseCourse (  )  {
        
        $course = Course_Choose::getInstance()->getCourseList();
                
        include TPL_DIR.'course.php';
        
    }
    
    /**
     * 获取所属大类课程的所有小类课程
     */
    public function getCourseName(){
        
        $con = $this->getParamString('con');//配置Internet防火墙
        $sunCourse = Course_Choose::getInstance()->getSonCourse($con);
        $html = '';
        foreach ($sunCourse as $key => $value) {
            $html.= $value['name'].'<input type="checkbox" name="like[]" value='.$value['tag'].'>';
        }
        echo $html;
    }
    /**
     * 播放视频
     */
    public function playCourse(){
        
        include TPL_DIR.'play2.php';
    }
    /**
     * 用户选择课程记入数据库
     */
    public function insertCourse () {
        $cou = $this->getParamIntArray('like');
        //添加到数据库
        foreach( $cou as $key => $value){
            $decimal[] = pow( 2, $value-1);
           
        }
        $sum = array_sum( $decimal);
        User_Info::getInstance()->selectCourse( array( 'courseTag' => $sum) );
       
        
        Helper_Url::redirect('index.php?con=Index&act=member');
       
    }
    /**
     * 课程管理
     */
    public function Course(){
        
        include TPL.'myCourse.php';
        
    }
}
?>
